<?php
/**
 * Description: 获取教师信息
 * User: devforma
 * Date: 15/4/28
 * Time: 16:11
 */

class GetTeacherInfo implements iController {
    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs) {
        global $cmsdb;
        
        if (empty($queryArgs['teacher_id']))
            return genOutput(1000);

        $info = $cmsdb->getRow('SELECT * FROM `data_teacher` WHERE `id`=:tid',
            array(':tid' => $queryArgs['teacher_id']));

        if (empty($info))
            return genOutput(1000);

        return genOutput(1, array(
            'teacher' => array(
                'id' => intval($queryArgs['teacher_id']),
                'name' => $info->name,
                'avatar' => empty($info->avatar) ? '' : $info->avatar,
                'introduction' => empty($info->introduction) ? '' : $info->introduction
            )
        ));
    }
}